from src.modules import db
from datetime import datetime

class Document(db.Model):
    __tablename__ = 't_system_document'
    id = db.Column(db.String(50), primary_key = True)
    document_name = db.Column(db.String(100))
    document_type = db.Column(db.String(10))
    document_size = db.Column(db.Integer)
    library_number = db.Column(db.String(20))
    document_summary = db.Column(db.String(1000))
    upload_time = db.Column(db.DateTime, default = lambda: datetime.now())

    def to_dict(self):
        d = {i.name: getattr(self, i.name) for i in self.__table__.columns}
        return d
